package com.coffeeloversupportlibrary.coffeelover.contentshow;

import android.util.Log;

import com.coffeeloversupportlibrary.coffeelover.callback.ModelCallBack;
import com.coffeeloversupportlibrary.core.base.BaseViewModel;
import com.coffeeloversupportlibrary.core.base.livadata.SingleLiveEvent;
import com.coffeeloversupportlibrary.core.data.DataRepository;

/**
 * @author puyv
 * @createTime 2021/11/22 20:13
 * @projectName CoffeeLoverSupportLibrary
 * @className ArticleDetailsViewModel.java
 * @description TODO
 */
public class ArticleDetailsViewModel extends BaseViewModel<ArticleDetailsModel> {


    private SingleLiveEvent<String> articleContent=new SingleLiveEvent<>();

    public SingleLiveEvent<String> getArticleContent(){
        return this.articleContent;
    }

    public void loadArticle(String id){
         mModel.getArticleDetails(new ModelCallBack<String, String>() {
             @Override
             public void onSuccess(String s) {
                 articleContent.setValue(s);
             }

             @Override
             public void Failure(String s) {
                 Log.e("TAG",s);
             }
         }, id);
    }

    @Override
    protected void setModel() {
        mModel=new ArticleDetailsModel(DataRepository.getInstance());
    }
}
